let app = getApp()
Component({
    properties: {
 
      },
      data:{
         page:1,
         class_id:0
      },
    lifetimes: {
        attached: function () {
           var id= wx.getStorageSync('linkinfo').id;
           if(typeof(id)!='undefined'){
             this.setData({
              class_id:id
             })
           }
           this.get_data()
       }
      },
    methods: {
         get_data:function(){
         var that=this
          wx.request({
            url: app.globalData.siteroot,
            data: { 
              do:'Goods_getGoods',
              class_id:that.data.class_id,
              page:that.data.page,
              page_size:20,
              user_id:wx.getStorageSync('user_id')
            },
            success: function(res) {
              var goodsdata=[];
              for(var s=0;s<res.data.data.length; s++){
                var obj = {
                  id:res.data.data[s].id,
                  image:res.data.data[s].pic,
                  distribute:res.data.data[s].distribute,
                  title:res.data.data[s].goods_name,
                  market_price:res.data.data[s].market_price,
                  price:res.data.data[s].price,
                  sales_volume:res.data.data[s].sales_volume
                 }
                 goodsdata.push(obj);
              }
               that.setData({
                list:goodsdata
               })  
            }
          })
         }
    }
});
